<?php

namespace App\Model;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Model\SystemMsg
 *
 * @property int $id
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg whereId($value)
 * @mixin \Eloquent
 * @property int $to_user_id 1提现成功 2提现失败 3克隆 4邀请好友营销奖励
 * @property int $type
 * @property string $title
 * @property string $content
 * @property float $money
 * @property \Illuminate\Support\Carbon|null $created_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg whereContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg whereMoney($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg whereToUserId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\SystemMsg whereType($value)
 */
class SystemMsg extends Model
{
	const CASH_OK = 1; //提现成功
	const CASH_FAIL = 2;    //提现失败
	const CLONE = 3;    //克隆奖励
	const INVITE = 4;    //邀请好友奖励

	protected $table = 'system_msg';

	/**
	 * @param $to_user_id 发送给哪个用户
	 * @param $type 类型
	 * @param $title 标题
	 * @param $content 内容
	 * @param $money 金额
	 * @return bool
	 */
	public static function add($to_user_id, $type, $title, $content, $money): bool
	{
		return self::insert([
			'to_user_id' => $to_user_id,
			'type' => $type,
			'title' => $title,
			'content' => $content,
			'money' => $money,
			'created_at' => Carbon::now(),
		]);
	}
}
